package com.test.deencredit.dialog_deencredit;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.test.deencredit.R;


public class PhotoSelectorDialog_deencredit extends Dialog {

    private final Runnable takeAPhotoRunnable_deencredit, fromAlbumRunnable_deencredit;

    public PhotoSelectorDialog_deencredit(@NonNull Context context, Runnable takeAPhotoRunnable, Runnable fromAlbumRunnable) {
        super(context);
        this.takeAPhotoRunnable_deencredit = takeAPhotoRunnable;
        this.fromAlbumRunnable_deencredit = fromAlbumRunnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_photo_selector_deencredit);

        getWindow().setBackgroundDrawableResource(R.color.transparent);
        setCanceledOnTouchOutside(false);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        initView_deencredit();
    }

    @SuppressLint("SetTextI18n")
    private void initView_deencredit(){

        findViewById(R.id.dps_ib_close).setOnClickListener(v -> dismiss());

        findViewById(R.id.dps_view_takephoto).setOnClickListener(v -> {
            if (takeAPhotoRunnable_deencredit !=null) takeAPhotoRunnable_deencredit.run();
            dismiss();
        });

        findViewById(R.id.dps_view_fromalbum).setOnClickListener(v -> {
            if (fromAlbumRunnable_deencredit !=null) fromAlbumRunnable_deencredit.run();
            dismiss();
        });

    }
}
